package thread;

//礼让不一定成功
public class ThreadYield {

    public static void main(String[] args) {
        MyYield myYield1 = new MyYield();
        MyYield myYield2 = new MyYield();
        new Thread(myYield1,"A").start();
        new Thread(myYield2,"B").start();
    }

}

class MyYield implements Runnable {
    @Override
    public void run() {
        System.out.println(Thread.currentThread().getName()+"线程启动");
        Thread.yield();
        System.out.println(Thread.currentThread().getName()+"线程终止");
    }
}
